/*
 * @Author: Broin
 * @Date: 2021-12-12 10:50:08
 * @LastEditTime: 2022-01-03 22:04:26
 * @LastEditors: Please set LastEditors
 * @Description: 
 * @FilePath: /ac_interface/src/utils/roles.js
 * MADE BY BROIN
 */
//import {platRoles, machineRoles} from '../config/roles';
//import {machineType} from '../config/virtualMachine';

export default class User {

    constructor(username, pRole, normalpass, rootpass){
        this.username = username;   //用户名
        this.pRole = pRole;         //平台角色
        this.normalpass = normalpass;   //普通权限口令
        this.rootpass = rootpass;       //root权限口令
        this.machines = [];             //该用户拥有的虚拟机
        this.vmRole = null;
    }

    //更改用户角色.
    changePlatRole(role) {
        this.pRole = role;
    }

    //更改用户名
    changeusername(username){
        this.username = username;
    }

    //更改普通权限口令
    changeNormalPass(password){
        if(password == this.rootpass || password == this.normalpass){
            alert("输入的密码与之前相同或与root口令相同，请重新修改");
        }
        else{
            this.normalpass = password;
        }
        
    }

    //更改Root权限口令
    changeRootPass(password){
        if(password == this.rootpass || password == this.normalpass){
            alert("输入的密码与之前相同或与普通权限口令相同，请重新修改");
        }
        else{
            this.rootpass = password;
        }
    }


    //关联虚拟机
    addMachine(name, IP, role) {
        let machine = {
            name : name,
            IP : IP,
            pRole : role
        }
        this.machines.push(machine);
    }
}